const joi = require("joi");

const username = joi.string().alphanum().min(1).max(10).required();
const password = joi
  .string()
  .pattern(/^[\S]{6,12}$/)
  .required();
const role = joi.number().min(0).max(1).required();
const avatar = joi.string().max(10000).required();
const nickname = joi.string().max(10).required();
const phone = joi.string().max(11).required();
const email = joi.string().email().required();
const id = joi.number().integer().min(1).required();
const website = joi.string().max(100).required();
const bio = joi.string().max(100).required();
exports.login_schema = {
  body: {
    username,
    password,
  },
};
exports.reg_schema = {
  body: {
    username,
    password,
    role,
    avatar,
    email,
  },
};

exports.updateInfo_schema = {
  body: {
    id,
    nickname,
    phone,
    email,
    avatar,
    website,
    bio,
  },
};

exports.updatePwd_schema = {
  body: {
    id,
    oldPwd: password,
    newPwd: joi.not(joi.ref("oldPwd")).concat(password),
  },
};
